package com.example.day19_7_19_1.adapter;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;

import java.util.ArrayList;
import java.util.List;

public class InfoVpAdapter extends FragmentPagerAdapter {
    private List<Fragment> list = new ArrayList<>();
    private List<String> title = new ArrayList<>();

    public void setTitle(List<String> title) {
        this.title.addAll(title);
        notifyDataSetChanged();
    }

    public InfoVpAdapter(@NonNull FragmentManager fm) {
        super(fm);
    }

    public void setList(List<Fragment> list) {
        this.list.addAll(list);
        notifyDataSetChanged();
    }

    @NonNull
    @Override
    public Fragment getItem(int position) {
        return list.get(position);
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Nullable
    @Override
    public CharSequence getPageTitle(int position) {
        return title.get(position);
    }
}
